package ru.efimmatytsin.tweeterella.converters;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.convert.converter.Converter;
import org.springframework.stereotype.Component;
import ru.efimmatytsin.tweeterella.entities.Photo;
import ru.efimmatytsin.tweeterella.viewmodels.PhotoViewModel;
import ru.efimmatytsin.tweeterella.viewmodels.PostViewModel;

/**
 * Created by Efim Matytsin on 22.02.15.
 */
@Component
public class PhotoToPostViewModelConverter implements Converter<Photo,PostViewModel> {
    @Autowired
    private PhotoViewModelConverter converter;

    @Override
    public PostViewModel convert(Photo photo) {
        PostViewModel<PhotoViewModel> postViewModel = new PostViewModel<PhotoViewModel>();
        postViewModel.setType("photo");
        postViewModel.setItem(converter.convert(photo));
        return postViewModel;
    }
}
